home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / STDLIB.PAK / MISMATCH.CPP < prev    next >
Text File  |  1997-05-06  |  956b  |  34 lines

  1.  #include <algorithm>
  2.  #include <vector>
  3.  
  4.  using namespace std;
  5.  
  6.  int main ()
  7.  {
  8.    typedef vector<int>::iterator  iterator;
  9.    int d1[4] = {1,2,3,4};
  10.    int d2[4] = {1,3,2,4};
  11.    //
  12.    // Set up two vectors.
  13.    //
  14.    vector<int> vi1(d1+0, d1+4), vi2(d2+0, d2+4);
  15.    //
  16.    // p1 will contain two iterators that point to the first pair of
  17.    // elements that are different between the two vectors.
  18.    //
  19.    pair<iterator, iterator> p1 = mismatch(vi1.begin(), vi1.end(), vi2.begin());    
  20.    //
  21.    // Find the first two elements such that an element in the
  22.    // first vector is greater than the element in the second vector.
  23.    //
  24.    pair<iterator, iterator> p2 = mismatch(vi1.begin(), vi1.end(),
  25.                                           vi2.begin(), less_equal<int>());
  26.    //
  27.    // Output results.
  28.    //
  29.    cout << *p1.first << ", " << *p1.second << endl;
  30.    cout << *p2.first << ", " << *p2.second << endl;
  31.  
  32.    return 0;
  33.  }
  34.